package com.cy.ppj.dao.mapper.statistics;

import com.cy.ppj.model.domian.statistics.StatisticsUser;
import com.cy.ppj.model.vo.admin.statistics.StatisticsUserVO;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.BaseMapper;

import java.util.Date;
import java.util.List;

@Mapper
public interface StatisticsUserMapper extends BaseMapper<StatisticsUser> {

    @Select(" SELECT count(u.id) FROM t_user u WHERE u.create_time BETWEEN #{startTime} AND #{endTime} ")
    int statisticsUser(@Param("startTime") Date startTime, @Param("endTime") Date endTime);

    @Select(" SELECT su.count, su.`date` FROM t_statistics_user su WHERE su.`date` BETWEEN #{startTime} AND #{endTime} ORDER BY `date` ASC ")
    List<StatisticsUserVO> selectStatisticsUserVO(@Param("startTime") Date startTime, @Param("endTime") Date endTime);
    
    @Select(" SELECT IFNULL(sum(su.count), 0) FROM t_statistics_user su ")
    int selectAllSumUserCount();
    
    @Select(" SELECT IFNULL(sum(su.count), 0) FROM t_statistics_user su WHERE su.`date` BETWEEN #{startTime} AND #{endTime} ")
    int selectSumUserCountByTime(@Param("startTime") Date startTime, @Param("endTime") Date endTime);
}
